package com.pucong.gitee.database.backup.business.service.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.pucong.gitee.database.backup.business.service.service.ServiceLinuxLogService;
import com.pucong.gitee.database.backup.common.entity.service.ServiceLinuxLog;
import com.pucong.gitee.database.backup.common.entity.service.dto.ServiceLinuxLogSelectDto;
import com.pucong.gitee.database.backup.utils.Res;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author pucong
 */
@RestController
@RequestMapping("/auto/linuxLog")
@Api(tags = "linux 命令执行记录 API")
public class ServiceLinuxLogController {

    @Autowired
    private ServiceLinuxLogService serviceLinuxLogService;

    @GetMapping("/getLinuxLogListByPage/{pageNum}/{pageSize}")
    @ApiOperation(value = "分页查询")
    public Res<IPage<ServiceLinuxLog>> getLinuxLogListByPage(@ApiParam(value = "页数",example = "1")@PathVariable("pageNum") int pageNum,
                                                             @ApiParam(value = "一页大小",example = "10")@PathVariable("pageSize") int pageSize,
                                                             ServiceLinuxLogSelectDto dto){
        IPage<ServiceLinuxLog> serviceLinuxLogIPage = serviceLinuxLogService.getLinuxLogListByPage(pageNum,pageSize, dto);
        return Res.ok(serviceLinuxLogIPage);
    }

    @GetMapping("/getLinuxLogById/{id}")
    @ApiOperation(value = "根据主键查询")
    public Res<ServiceLinuxLog> getLinuxLogById(@ApiParam("主键")@PathVariable("id") String id){
        ServiceLinuxLog serviceLinuxLog = serviceLinuxLogService.getLinuxLogById(id);
        return Res.ok(serviceLinuxLog);
    }
}
